package com.chanel.iamframework.core.service;

import javax.validation.Valid;
import javax.validation.constraints.NotNull;

import com.chanel.iamframework.core.domain.User;
import com.chanel.iamframework.validation.annotation.Validate;

@Validate
public interface UserService {

	/**
	 * Persiste User entity
	 * @param user entity
	 * @return true if the object is persisted, false otherwise.
	 */
	void createUser(@NotNull @Valid User user);

	/**
	 * Get User by Identity
	 * @param userId Identity of User
	 * @return Users entity
	 */
	User getUser(@NotNull Long userId);

	/**
	 * Update User entity
	 * @param user entity
	 * @return true if the object is persisted, false otherwise.
	 */
	boolean updateUser(@NotNull @Valid User user);
	
	/**
	 * Delete User by Identity
	 * @param userId Identity
	 * @return true if the object is persisted, false otherwise.
	 */
	boolean deleteUser(@NotNull Long userId);

	/**
	 * Load Groups by UserId into the returned {@link User} instance.
	 * @param userId identity
	 * @return {@link User} instance with list of {@link com.chanel.iamframework.core.domain.Group}
	 */
	User loadGroups(@NotNull Long userId);

	/**
	 * Load Application by userId into the returned {@link User} instance.
	 * @param userId identity
	 * @return {@link User} instance with list of {@link com.chanel.iamframework.core.domain.Application}
	 */
	User loadApplications(@NotNull Long userId);

	/**
	 * Load Role by userId into the returned {@link User} instance.
	 * @param userId identity
	 * @return {@link User} instance with list of {@link com.chanel.iamframework.core.domain.Role}
	 */
	User loadRoles(@NotNull Long userId);
	
	/**
	 * Add User, Groups association
	 * @param user {@link User} instance with list of {@link com.chanel.iamframework.core.domain.Group}
	 */
	void addGroups(@NotNull User user);

	/**
	 * Delete Group, User association
	 * @param groupId identity
	 * @param userId identity
	 * @return The number of rows affected by the insert
	 */
	/**
	 * Delete User, Groups association
	 * @param user user {@link User} instance with list of {@link com.chanel.iamframework.core.domain.Group}
	 * @return true if the object is persisted, false otherwise.
	 */
	boolean deleteGroups(@NotNull User user);
}
